<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('订单主列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>订单编号：</p>
                                <input type="text" name="orderSn"/>
                            </li>
                            <li>
                                <p>订单状态：</p>
                                <select name="orderStatus">
                                    <option value="">所有</option>
                                    <option value="-1" >已取消</option>
                                    <option value="0" >待付款</option>
                                    <option value="1" >已付款</option>
                                    <option value="2" >已发货</option>
                                    <option value="3" >退货中</option>
                                    <option value="4" >退货完成</option>
                                    <option value="5" >待评价</option>
                                    <option value="6" >已评价</option>
                                </select>
                            </li>
                            <li>
                                <p>手机：</p>
                                <input type="text" name="mobile"/>
                            </li>
                            <li>
                                <p>物流单号：</p>
                                <input type="text" name="shippingCode"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
<!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="shop:order:add">-->
<!--                    <i class="fa fa-plus"></i> 添加-->
<!--                </a>-->
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="shop:order:edit">
                    <i class="fa fa-edit"></i> 发货
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="shop:order:remove">
                    <i class="fa fa-remove"></i> 取消订单
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="shop:order:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" data-mobile-responsive="true"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('shop:order:edit')}]];
        var removeFlag = [[${@permission.hasPermi('shop:order:remove')}]];
        var prefix = ctx + "shop/order";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "订单主",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'orderId', 
                    title : '订单id',
                    visible: false
                },
                {
                    field : 'orderSn', 
                    title : '订单编号'
                },
                {
                    field : 'storeMember',
                    title : '用户信息',
                    formatter: function (value) {
                        return value.nickname+"<br>"+value.phone;
                    }
                },
                {
                    field : 'orderStatusStr',
                    title : '订单状态'
                },

                {
                    field : 'storeOrderGoods', 
                    title : '商品信息',
                    formatter: function (value) {
                        var str = '';
                        for (var p in value) {
                            str+=value[p].goodsName+"("+value[p].specKeyName+")<br>";
                        }

                        return str;
                    }
                },

                {
                    field : 'orderAmount',
                    title : '应付款金额'
                },
                {
                    field : 'totalAmount', 
                    title : '订单总价'
                },
                {
                    field : 'addTime', 
                    title : '下单时间'
                    // formatter: function (value) {
                    //     return $.common.dateFormat('Y-m-d H:i:s',value);
                    // }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.orderId + '\')"><i class="fa fa-edit"></i>发货</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.orderId + '\')"><i class="fa fa-remove"></i>取消订单</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>